clear
cap log close

cd "D:\Dropbox\Work\Research\CreditCardABSRewrite\Draft\ReplicationFiles\Tab_12"

local today = "`c(current_date)'"
log using "Table_12_Log.log", text append


import delimited "Data_Table_12.csv"

* generate indicators for subperiods
generate pre=1 if year<2007
generate cri=1 if year>2006 & year<2010
generate post=1 if year>2009 & year<2021

* Table 10

*****************
* A Tranche
* All
regress riskprem_a chargeoff chargeofftrend i.year, vce(cluster year)
outreg2 using Tab12_A, stats(coef tstat) noaster adjr2 nocons title("A Tranche") ctitle("All") drop(i.year riskprem*) bdec(4) bfmt(f) tdec(2) tfmt(f) rdec(3) rfmt(f) word replace
* 2000-2006
regress riskprem_a chargeoff chargeofftrend i.year if pre==1, vce(cluster year)
outreg2 using Tab12_A, stats(coef tstat) noaster adjr2 nocons title("A Tranche") ctitle("2000-2006") drop(i.year riskprem*) bdec(4) bfmt(f) tdec(2) tfmt(f) rdec(3) rfmt(f) word 

* 2007-2009
regress riskprem_a chargeoff chargeofftrend i.year if cri==1, vce(cluster year)
outreg2 using Tab12_A, stats(coef tstat) noaster adjr2 nocons title("A Tranche") ctitle("2007-2009") drop(i.year riskprem*) bdec(4) bfmt(f) tdec(2) tfmt(f) rdec(3) rfmt(f) word

* 2010-2020
regress riskprem_a chargeoff chargeofftrend i.year if post==1, vce(cluster year)
outreg2 using Tab12_A, stats(coef tstat) noaster adjr2 nocons title("A Tranche") ctitle("2010-2020") drop(i.year riskprem*) bdec(4) bfmt(f) tdec(2) tfmt(f) rdec(3) rfmt(f) word


*******************
* B Tranche
* All
regress riskprem_b chargeoff chargeofftrend i.year, vce(cluster year)
outreg2 using Tab12_B, stats(coef tstat) noaster adjr2 nocons title("B Tranche") ctitle("All") drop(i.year riskprem*) bdec(4) bfmt(f) tdec(2) tfmt(f) rdec(3) rfmt(f) word replace

* 2000-2006
regress riskprem_b chargeoff chargeofftrend i.year if pre==1, vce(cluster year)
outreg2 using Tab12_B, stats(coef tstat) noaster adjr2 nocons title("B Tranche") ctitle("2000-2006") drop(i.year riskprem*) bdec(4) bfmt(f) tdec(2) tfmt(f) rdec(3) rfmt(f) word

* 2007-2009
regress riskprem_b chargeoff chargeofftrend i.year if cri==1, vce(cluster year)
outreg2 using Tab12_B, stats(coef tstat) noaster adjr2 nocons title("B Tranche") ctitle("2007-2009") drop(i.year riskprem*) bdec(4) bfmt(f) tdec(2) tfmt(f) rdec(3) rfmt(f) word

* 2010-2020
regress riskprem_b chargeoff chargeofftrend i.year if post==1, vce(cluster year)
outreg2 using Tab12_B, stats(coef tstat) noaster adjr2 nocons title("B Tranche") ctitle("2010-2020") drop(i.year riskprem*) bdec(4) bfmt(f) tdec(2) tfmt(f) rdec(3) rfmt(f) word


*******************
* C Tranche
* All
regress riskprem_c chargeoff chargeofftrend i.year, vce(cluster year)
outreg2 using Tab12_C, stats(coef tstat) noaster adjr2 nocons title("C Tranche") ctitle("All") drop(i.year riskprem*) bdec(4) bfmt(f) tdec(2) tfmt(f) rdec(3) rfmt(f) word replace

* 2000-2006
regress riskprem_c chargeoff chargeofftrend i.year if pre==1, vce(cluster year)
outreg2 using Tab12_C, stats(coef tstat) noaster  adjr2 nocons title("C Tranche") ctitle("2000-2006") drop(i.year riskprem*) bdec(4) bfmt(f) tdec(2) tfmt(f) rdec(3) rfmt(f) word

* 2007-2009
regress riskprem_c chargeoff chargeofftrend i.year if cri==1, vce(cluster year)
outreg2 using Tab12_C, stats(coef tstat) noaster adjr2 nocons title("C Tranche") ctitle("2007-2009") drop(i.year riskprem*) bdec(4) bfmt(f) tdec(2) tfmt(f) rdec(3) rfmt(f) word

* 2010-2020
regress riskprem_c chargeoff chargeofftrend i.year if post==1, vce(cluster year)
outreg2 using Tab12_C, stats(coef tstat) noaster  adjr2 nocons title("C Tranche") ctitle("2010-2020") drop(i.year riskprem*) bdec(4) bfmt(f) tdec(2) tfmt(f) rdec(3) rfmt(f) word

log close